const App = {
    mixins: [Save],//配置文件，路径/utils/mixins.js
    data() {
        return {
            city: [],
            land: [],
            ME: [],
            cityValue: [],
            MEvalue: [],//已选设备类型
            monitoring_equipment_tags: [],
            EquipmentViewTypeInfo: []
        };
    },
    mounted() {
        this.getCity();
        this.getLand();
        this.getMEvalue();
        this.changeCity(this.dataForm.County_Nubmer)
    },
    watch: {
        'dataForm.Monitoring_Equipment_Detail_SerialNumber'(val) {
            // this.cityValue = [this.dataForm.Province_Number, this.dataForm.Ctiy_Number, this.dataForm.County_Number, this.dataForm.Town_Number];
            // if (this.ME.length > 0) {
            //     this.isMEvalue();
            // }

            if (this.dataForm.EquipmentViewType) {
                this.dataForm.EquipmentViewTypeHtml = this.dataForm.EquipmentViewType.split(",");
            }
        },

    },
    methods: {
        // changeCity(val){
        //     if (val) {
        //         this.dataForm.Province_Number = val.substring(0, 2) + '0000';
        //         this.dataForm.Ctiy_Number = val.substring(0, 4) + '00';
        //         $.ajax({
        //           headers: requestHeaders(),
        //           url: `${mh}/clientOperation/getDistrictTree`,
        //           type: "GET",
        //           data: {
        //             DistrictCode: val,
        //           },
        //           success: (data) => {
        //             this.city1 = data[0].children;
        //           },
        //           complete: (XMLHttpRequest) => {
        //             requestPretreatment(XMLHttpRequest);
        //           },
        //           dataType: "json",
        //         });
        //       } else {
        //         this.dataForm.Province_Number = '';
        //         this.dataForm.City_Number = '';
        //         this.dataForm.County_Nubmer = '';
        //         this.dataForm.Town_Number = '';
        //         this.dataForm.Village_Number = '';
        //       }
        // },
        handleChange(val) {



            this.dataForm.EquipmentViewType = val.join(",");




        },
        getCity() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/permissionsTree/getDistrictTreeByPermissions`,
                type: "GET",
                data: {
                    DistrictCode: getCookie('village'),

                },
                success: (data) => {
                    this.city = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: 'POST',
                data: {
                    Data: 'monitoring_equipment_tags',
                    Condition: "Row_Status='0'",
                },
                success: (res) => {
                    this.monitoring_equipment_tags = res;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json"
            });

            $.ajax({
                url: `${absolutepath()}api/EquipmentViewType.json`,
                method: "get",
                success: (data) => {
                    this.EquipmentViewTypeInfo = data;

                },
            })
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: 'POST',
                data: {
                    Data: 'grid_information',
                    Condition: "Row_Status='0'",
                },
                success: (res) => {
                    this.grid_information = res;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json"
            });
        },
        getLand() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: 'POST',
                data: {
                    Data: 'natural_resources_management',
                    Condition: "Row_Status='0'",
                },
                success: (res) => {
                    this.land = res;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json"
            });

        },
        getMEvalue() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryForObtainingTrees`,
                type: "GET",
                data: {
                    TableName: 'monitoring_equipment',
                    NodeCode: '',
                },
                success: (data) => {
                    this.ME = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
        },
        changeCity(val) {
            if (val) {
                this.dataForm.Province_Number = val.substring(0, 2) + '0000';
                this.dataForm.Ctiy_Number = val.substring(0, 4) + '00';
                this.dataForm.County_Number = val.substring(0, 6);
                this.dataForm.Town_Number = val.substring(0, 9);;
            } else {
                this.dataForm.Province_Number = '';
                this.dataForm.Ctiy_Number = '';
                this.dataForm.County_Number = '';
                this.dataForm.Town_Number = '';
            }
        },
    },
};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
